﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

public partial class CMS_Admin_block_VoteCount : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            VoteBind(Convert.ToInt32(Request["id"]),Server.UrlDecode(Request["name"]));
        }
    }

    private void VoteBind(int id,string c_name)
    {
        name.InnerText = c_name;
        Usas.BLL.Cms.cms_block_common_detail_option cop = new Usas.BLL.Cms.cms_block_common_detail_option();

        DataSet ds = cop.GetList("o_c_id=" + id);
        StringBuilder sbr = new StringBuilder();
        if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
        {
            sbr.Append("$(document).ready(function() {");
            sbr.Append(" $(\"#vote\").study_vote([");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {

                sbr.Append("{ \"name\": \"" + ds.Tables[0].Rows[i]["o_name"].ToString()
                    + "\", \"data\": \"" + ds.Tables[0].Rows[i]["o_value"].ToString() + "\", \"color\": \"#000\", \"art\": \"return false\" }");
                if (i != ds.Tables[0].Rows.Count - 1)
                {
                    sbr.Append(",");
                }
            }
            sbr.Append("],null);});");
            ClientScript.RegisterStartupScript(GetType(), "Msg", sbr.ToString(), true);
        }
    }
}
